﻿$(function () {
    window.top.$("#myModal").on("hidden.bs.modal", function () {
        $("#frmModal").attr({ "src": "" });
    });
})

function showChildModal(frameSrc, otitle, width, height) {
    if (frameSrc.indexOf("?") > 0) {
        frameSrc = frameSrc + '&rd=' + $.now();
    } else {
        frameSrc = frameSrc + '?rd=' + $.now();
    }


    $("#frmModal").attr({ "src": frameSrc, "height": height - 26 });//设置iframe地址

    $("#myModal").modal({ show: true, backdrop: 'static' });//弹出modal,设置点击空白处  无关闭窗口,但是ESC会关闭

    var myCss = { "width": width + "px", "height": height + "px", "position": "fixed", "left": "50%", "top": "50%", "margin": "-" + (height / 2 + 30) + "px 0 0 -" + width / 2 + "px" };

    $('.modal-dialog').css(myCss);
    $(".modal-dialog").find('.modal-content').find('h4').html(otitle || "");

    return false;
}

function closeChildModal() {
    window.parent.$("#myModal").modal('hide');
}

function showModal(frameSrc, otitle, width, height) {
    if (frameSrc.indexOf("?") > 0) {
        frameSrc = frameSrc + '&rd=' + $.now();
    } else {
        frameSrc = frameSrc + '?rd=' + $.now();
    }


    window.top.$("#frmModal").attr({ "src": frameSrc, "height": height - 26 });//设置iframe地址

    window.top.$("#myModal").modal({ show: true, backdrop: 'static' });//弹出modal

    var myCss = { "width": width + "px", "height": height + "px", "position": "fixed", "left": "50%", "top": "50%", "margin": "-" + (height / 2 + 30) + "px 0 0 -" + width / 2 + "px" };

    window.top.$('.modal-dialog').css(myCss);
    window.top.$(".modal-dialog").find('.modal-content').find('h4').html(otitle || "");

    return false;
}

function closeModal() {
    window.top.$("#myModal").modal('hide');
}